package com.zzy.algorithm.tree;

import com.zzy.algorithm.model.TreeNode;

/**
 * LeetCode - 226 ：翻转二叉树
 *
 * 给你一棵二叉树的根节点 root ，翻转这棵二叉树，并返回其根节点。
 */
public class Q24_OverturnBinaryTree {

    public static void main(String[] args) {
        Q24_OverturnBinaryTree q24_overturnBinaryTree = new Q24_OverturnBinaryTree();
        q24_overturnBinaryTree.solution(TreeNode.treeNode1);
    }

    private TreeNode solution(TreeNode root){
        if(root == null){
            return null;
        }
        TreeNode leftNode = solution(root.left);
        TreeNode rightNode = solution(root.right);
        root.left = rightNode;
        root.right = leftNode;
        return root;
    }

}
